<template>
  <div>
    <el-table :data="warehouseInfos">
      <el-table-column prop="id" label="编号"></el-table-column>
      <el-table-column prop="warName" label="仓库名"></el-table-column>
      <el-table-column prop="warMaxStock" label="仓库最大库存"></el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button
            round
            type="primary"
            plain
            @click="Dispatch(scope.row)"
          >调度仓库商品</el-button>
        </template>
      </el-table-column>
    </el-table>
    <div>
      <!-- 分页 -->
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="pageno"
        :page-sizes="[5, 10, 15, 20]"
        :page-size="pagesize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      >
      </el-pagination>
    </div>
    <div>
      <component ref="Dispatch" is="Dispatch_warehouse_goods"></component>
    </div>
  </div>
</template>

<script>
  import Dispatch_warehouse_goods from "./Dispatch_warehouse_goods";
    export default {
        name: "Warehouse_cargo_allocation",
      data(){
          return{
            warehouseInfos:[],
            pageno: 1,
            pagesize: 5,
            total: 1
          }
      },
      methods:{
          getwarehousedata(){
            var obj={
              pageno:this.pageno,
              pagesize:this.pagesize,
            }
            this.$axios.get("warehouseInfo/queryAllWarehouseInfo.action",{params:obj}).then(res=>{
              this.warehouseInfos=res.data.records;
              this.total=res.data.total;
            }).catch(error=>{
              this.$message.error(error)
            })
          },
        handleSizeChange(val) {
          //每页范围
          this.pagesize = val;
          this.getdataordersCarryFreight();
        },
        handleCurrentChange(val) {
          //当前页
          this.pageno = val;
          this.getdataordersCarryFreight();
        },
        Dispatch(row){
          this.$refs.Dispatch.dialogTableVisible=true;
          this.$refs.Dispatch.WarehouseDetails.pId=row.id;
          sessionStorage.setItem("Add_the_warehouse_wname",row.warName);
          this.$refs.Dispatch.getDispatch_warehouse_goods()
        }
      },
      created() {
          this.getwarehousedata()
      },
      components:{
        Dispatch_warehouse_goods
      }
    }
</script>

<style scoped>

</style>
